import org.junit.Test;

import java.util.Arrays;

public class TwoSelect {
    @Test
    public void test() {
        int args[] = {11, 22, 33, 44, 55, 66, 77, 88, 99};
        int low = 0;
        int height = args.length - 1;
        int key = 66;
        while (low <= height) {
            int middle = (height + low) / 2;
            if (args[middle] == key) {
                System.out.println("找到了..." + args[middle]);
                return;
            }
            if (args[middle] < key) {
                low = middle + 1;
            }
            if (args[middle] > key) {
                height = middle - 1;
            }
        }
        System.out.println("not find...");
    }

    @Test
    public void Maopao() {
        int args[] = {55, 2, 5, 45, 88, 1, 7, 9, 89};
        for (int i = 0; i < args.length; i++) {
            for (int j = args.length - 1; j > i; j--) {
                if (args[j] > args[j - 1]) {
                    int temp = 0;
                    temp = args[j];
                    args[j] = args[j - 1];
                    args[j - 1] = temp;
                }

            }
        }
        System.out.println(Arrays.toString(args));
        int low = 0;
        int height = args.length - 1;
        int key = 45;
        while (low <= height) {
            int mid = (low + height) / 2;
            if (args[mid] == key) {
                System.out.println("找到了..." + args[mid]);
                return;
            }
            if (args[mid] < key) {
                low = mid + 1;
            }
            if (args[mid] > key) {
                height = mid - 1;
            }
        }
        System.out.println("not find...");
    }
}
